AUTO
AUTO variables are accessible to one instance of a single function. Each time the function
is called a new set of AUTO variables are assigned to CPU registers or memory on the local
frame, so several sets of a function's AUTO variables may exist at any time, each of which
is accessible to only one instance of the function. AUTO variables are temporary,
they exist only until the function completes and returns to the caller. Variables
are AUTO by default, so all undeclared variables are AUTO.
In well written programs, most variables are AUTO. They are the default because they
are completely insulated from all other functions and programs, including other instances
of the same function.
AUTO variables are assigned to registers in the order they appear, so putting important
variables in AUTO statements will cause as many as possible to be assigned to registers.
When registers are no longer available, AUTO variables are assigned locations on
the local stack frame along with AUTOX variables. Executing from registers is
faster, so register variables can speed program execution.
AUTOX
AUTOX variables are the same as AUTO variables except they are always assigned locations
on the local stack frame, never in CPU registers. Numeric variables whose addresses
are taken must not be declared AUTO, since CPU registers do not have addresses.
String, array, and composite variables whose handle addresses are taken must not be
declared AUTO for the same reason. AUTOX is generally needed only when calling C
functions written to receive arguments that are addresses.
STATIC
STATIC variables are accessible to all instances of a single function. STATIC
variables are assigned fixed memory locations for the lifetime of the program, so they are
local to a single function, but common to all instances of the function, and their values
persist between function calls.
SHARED
SHARED variables are accessible to all functions in a single program that declare SHARED
variables of the same name. SHARED variables are allocated space at fixed memory
locations for the program lifetime, so their values persist between calls of the functions
that access them, and are common to all functions that access them.
A # prefix on a variable name declares the variable as SHARED, even when the variable is
not declared in a SHARED statement.